import request from '@/utils/request';

/**
 * 获取小程序设置信息
 */
export function apiGetConfig() {
    return request.get('/config/get-mini');
}

export function apiSetConfig(parma) {
    let data = new FormData();
    for (let key in parma) {
        data.append(key, parma[key]);
    }
    return request({
        method: 'post',
        url: '/config/set-mini',
        headers: {
            "Content-Type": " multipart/form-data"
        },
        transformRequest: null,
        data
    })
}

/**
 * 获取营业时间
 */
export function apiGetCofTime() {
    return request.get('/config/time-limit')
}
/**
 * 
 * @param {开始时间} start_time 
 * @param {结束时间} end_time 
 * @returns 
 */
export function apiSetCofTime(start_time, end_time) {
    return request({
        method: 'post',
        url: '/config/update',
        data: {
            start_time,
            end_time
        }
    });
}

/**
 * 其他自定义配置
 */
export function apiSetConfigQiTa(key, value) {
    return request.post('/config/save', {
        config_name: key,
        config_value: value
    })
}

/**
 * 获取自定义配置
 */

export function apiGetConfigQiTa(key) {
    return request.get('/config/view', {
        params: {
            name: key
        }
    })
}